package top.lingkang.sprites;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import top.lingkang.screen.PlayScreen;

public class BackgroundSprite extends Sprite {
    private PlayScreen playScreen;
    private TextureAtlas atlas;

    public BackgroundSprite(PlayScreen playScreen) {
        this.playScreen = playScreen;
        atlas = new TextureAtlas(Gdx.files.internal("bg/bg_1/bg_1.atlas"));
        TextureRegion texture = atlas.getRegions().get(0);
        setRegion(texture);
    }

    private float move = -5f;

    public void update(float delta) {
        move += delta * 3f;
        playScreen.batch.draw(this, move, 0f,
                0, 0,
                507, 204,
                0.05f, 0.05f, 0);
    }

    public void dispose() {
        atlas.dispose();
    }
}
